package com.yanfan.ccapi.controller;

import com.yanfan.ccapi.service.ICcapiDeviceCapabilityService;
import com.yanfan.ccapicode.dao.entity.DeviceCapabilityDO;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.core.page.TableDataInfo;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 第三平台能力映射Controller
 *
 * @author kerwincui
 * @date 2025-06-29
 */
@RestController
@RequestMapping("/ccapi/deviceCapability")
@Api(tags = "第三平台能力映射")
public class CcapiDeviceCapabilityController extends BaseController {
    @Autowired
    private ICcapiDeviceCapabilityService ccapiDeviceCapabilityService;

    /**
     * 查询第三平台能力映射列表
     */
//@PreAuthorize("@ss.hasPermi('ccapi:deviceCapability:list')")
    @GetMapping("/list")
    @ApiOperation("查询第三平台能力映射列表")
    public TableDataInfo list(DeviceCapabilityDO ccapiDeviceCapability) {
        startPage();
        List<DeviceCapabilityDO> list = ccapiDeviceCapabilityService.selectCcapiDeviceCapabilityList(ccapiDeviceCapability);
        return getDataTable(list);
    }

    /**
     * 导出第三平台能力映射列表
     */
    @ApiOperation("导出第三平台能力映射列表")
    //@PreAuthorize("@ss.hasPermi('ccapi:deviceCapability:export')")
    @Log(title = "第三平台能力映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceCapabilityDO ccapiDeviceCapability) {
        List<DeviceCapabilityDO> list = ccapiDeviceCapabilityService.selectCcapiDeviceCapabilityList(ccapiDeviceCapability);
        ExcelUtil<DeviceCapabilityDO> util = new ExcelUtil<DeviceCapabilityDO>(DeviceCapabilityDO.class);
        util.exportExcel(response, list, "第三平台能力映射数据");
    }

    /**
     * 获取第三平台能力映射详细信息
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:deviceCapability:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取第三平台能力映射详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ccapiDeviceCapabilityService.selectCcapiDeviceCapabilityById(id));
    }

    /**
     * 新增第三平台能力映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:deviceCapability:add')")
    @Log(title = "第三平台能力映射", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增第三平台能力映射")
    public AjaxResult add(@RequestBody DeviceCapabilityDO ccapiDeviceCapability) {
        return toAjax(ccapiDeviceCapabilityService.insertCcapiDeviceCapability(ccapiDeviceCapability));
    }

    /**
     * 修改第三平台能力映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:deviceCapability:edit')")
    @Log(title = "第三平台能力映射", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改第三平台能力映射")
    public AjaxResult edit(@RequestBody DeviceCapabilityDO ccapiDeviceCapability) {
        return toAjax(ccapiDeviceCapabilityService.updateCcapiDeviceCapability(ccapiDeviceCapability));
    }

    /**
     * 删除第三平台能力映射
     */
    //@PreAuthorize("@ss.hasPermi('ccapi:deviceCapability:remove')")
    @Log(title = "第三平台能力映射", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除第三平台能力映射")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ccapiDeviceCapabilityService.deleteCcapiDeviceCapabilityByIds(ids));
    }
}
